package com.jinghaizhao.gqgl.user.control;



import com.jinghaizhao.gqgl.mybatis.entity.PtUserEntity;
import com.jinghaizhao.gqgl.user.entity.SearchUserEntity;
import com.jinghaizhao.gqgl.spring.control.BaseController;
import com.jinghaizhao.gqgl.user.service.UserService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.MessageSource;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController extends com.jinghaizhao.gqgl.spring.control.BaseController {
    private Logger logger = LogManager.getLogger(this.getClass());
    @Resource
    private UserService userService;


    @RequestMapping("/queryUserInfoListByName")
    @ResponseBody
    public List<PtUserEntity> queryUserInfoListByName(SearchUserEntity search){
        logger.info(search);
        List<PtUserEntity> list = userService.queryUserInfoListByName(search);
        return list;
    }
    @RequestMapping("/deleteUserInfoByIds")
    @ResponseBody
    public String deleteUserInfoByIds(@RequestParam(value = "ids",required = false) String ids){
        logger.info("ids:" + ids);

        try {
            userService.deleteUserInfoByIds(ids);
        } catch (UncategorizedSQLException e) {
            e.printStackTrace();
            return jsonFail("user.del.user.fail");

        }
        return jsonSuccess("user.del.user.success");
    }
    }
